package my.ks;

/**
 * 0-1背包问题物品实体类
 *
 * @author AJun
 * @date 2020/11/25
 */
public class Article {

    /**
     * 权重
     */
    public int weight;

    /**
     * 价值
     */
    public int value;

    /**
     * 价值密度: 价值 / 重量
     */
    public double valueDensity;

    public Article(int weight, int value) {
        this.weight = weight;
        this.value = value;
        valueDensity = value * 1.0 / weight;
    }

    @Override
    public String toString() {
        return "Article [weight=" + weight + ", value=" + value +
            ", valueDensity=" + String.format("%.2f", valueDensity) + "]";
    }

}
